package com.weicoder.shop.po

import java.io.Serializable
import javax.persistence.Entity
import javax.persistence.Id
import org.hibernate.annotations.DynamicInsert
import org.hibernate.annotations.DynamicUpdate
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import com.weicoder.common.lang.Conversion
import com.weicoder.site.entity.base.BaseEntity
import scala.beans.BeanProperty
import java.math.BigDecimal

/**
 * 金币 直接与现金有挂钩的
 * @author WD
 * @since JDK6
 * @version 1._ 2_1_-11-1_
 */
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@Entity
@DynamicInsert
@DynamicUpdate
class Money extends BaseEntity with Serializable {
  // 用户ID
  @Id
  @BeanProperty
  var userId: Int = _
  // 金钱
  @BeanProperty
  var money: BigDecimal = _
  // 状态
  @BeanProperty
  var state: Integer = _

  override def getKey(): Serializable = userId

  override def setKey(key: Serializable) = this.userId = Conversion.toInt(userId)
}
